#include <iostream>
using namespace std;

class A1
{
public :
    virtual void f(){}
public:
    int _a1 = 0;
};
class A2
{
public:
    virtual void f(){}
public:
    int _a2 = 0;
};
class B : public A1, public A2
{
public:
    int _b = 0;
};
void fun (A1* pa)
{
    // dynamic_cast会先检查是否能转换成功，能成功则转换，不能则返回
    B* pb1 = static_cast<B*>(pa);
    B* pb2 = dynamic_cast<B*>(pa);
    cout<<"pb1:" <<pb1<< endl;
    cout<<"pb2:" <<pb2<< endl;
}
int main ()
{
    B bb;
    A1* ptr1 = &bb;
    A2* ptr2 = &bb;
    cout<< ptr1 << endl;
    cout<< ptr2 << endl << endl;
    B* pb1 = (B*)ptr1;
    B* pb2 = (B*)ptr2;

    cout<< pb1 << endl;
    cout<< pb2 << endl << endl;
    
    B* pb3 = dynamic_cast<B*>(ptr1);
    B* pb4 = dynamic_cast<B*>(ptr2);

    cout<< pb3 << endl;
    cout<< pb4 << endl << endl;

    return 0;
}
